<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery-1.12.4.min.js"></script>
    <script>
        $(function () {
            var $div = $('#div01');

            $div.prev().css({color:'red'}); //返回第一个p的对象
            $div.prevAll().css({color:'green'});
        })

    </script>
</head>
<body>
    <div>
        <h2> h2 标签</h2>
        <p> 段落标签</p>
        <div id="div01">这是一个div</div>
        <h3> h3 </h3>
        <p> 段落标签2</p>
    </div>

</body>
</html>